import baserun
import openai
async def answer_question(question: str):
# Download the template from Baserun based on the name and environment (`ENVIRONMENT` environment variable)
template = baserun.get_template("question_and_answer")
# Format the prompt, then send it to OpenAI
prompt = await baserun.format_prompt(
template_name=template.name,
template_messages=template.active_version.template_messages,
parameters={"question": question},
)
client = AsyncOpenAI()
completion = await client.chat.completions.create(
model="gpt-3.5-turbo",
messages=prompt,
)
return completion.choices[0].message.content